package axdoc.rule.def.impl.activity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;

import axdoc.rule.def.SignleRule;

public class CityRule extends SignleRule {

	private static Logger logger = LoggerFactory.getLogger(CityRule.class);

	@Override
	public String getName() {
		return "城市";
	}

	@Override
	public void initDefaultValue() {
		logger.info("[初始化城市选项][start]");
		ruleValues = infoService.getCities();
		logger.info("[初始化城市选项][end][" + (JSON.toJSONString(ruleValues)) + "]");
	}

	@Override
	public String toHtml() {
		StringBuffer html = new StringBuffer();
		html.append("<tr>");
		html.append("<td>").append(getName()).append("</td>");
		html.append(
				"<td><select id='city' name='city' class='easyui-combobox'  data-options=\"multiple:true,width:200,required:'required'\">");
		for (int i = 0; i < ruleValues.size(); i++) {
			html.append("<option value='").append(ruleValues.get(i).getId()).append("'>")
					.append(ruleValues.get(i).getName()).append("</option>");
		}
		html.append("</select></td>");
		html.append("</tr>");
		return html.toString();
	}

}
